/******************************************************************************
 *
 * Project:		mGameEngine
 * File:		brightnesscontrast.cpp
 * Author:		twoja stara
 * Created on:	2009-09-20
 *
 ******************************************************************************/

#include "brightnesscontrast.h"

namespace mGameEngine
{

namespace Graphics
{

BrightnessContrast::BrightnessContrast(float brightness, float contrast,
								const Texture *texture, RenderTarget *target) :
	PostProcess(NULL, texture, target),
	_brightness(brightness), _contrast(contrast)
{
	static const String &vertSrc
	(
#include "postprocess.vert"
	);
	static const String &fragSrc
	(
#include "brightnesscontrast.frag"
	);
	_gpuProgram = new GPUProgram(vertSrc, fragSrc);
	_gpuProgram->compile();

	setBrightness(brightness);
	setContrast(contrast);
}

BrightnessContrast::~BrightnessContrast()
{
}

void BrightnessContrast::setBrightness(float brightness)
{
	if(brightness < 0.0f)
	{
		return;
	}

	_brightness = brightness;

	if(_gpuProgram)
	{
		_gpuProgram->setValue("brightness", _brightness);
	}
}

void BrightnessContrast::setContrast(float contrast)
{
	if(contrast < 0.0f)
	{
		return;
	}

	_contrast = contrast;

	if(_gpuProgram)
	{
		_gpuProgram->setValue("contrast", _contrast);
	}
}

}
}

